package org.usp.poli.bipt.client.ui;

import com.google.gwt.event.dom.client.MouseOverEvent;
import com.google.gwt.event.dom.client.MouseOverHandler;
import com.google.gwt.user.client.Timer;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.PopupPanel;
import com.google.gwt.user.client.ui.PushButton;
import com.google.gwt.user.client.ui.Widget;

public class Buttons {
	private String imagem, texto;
	private PushButton btnMenu; 
	public Buttons(String imagem, final String texto, final PopupPanel textoDescritivo) {
		this.imagem = imagem;
		this.texto = texto;
		
		final Timer t = new Timer() {
			public void run() {
				textoDescritivo.hide();
			}
		};

		Image imgMenu = new Image("images/"+imagem+".jpg");
		
		btnMenu = new PushButton(imgMenu);
		btnMenu.setPixelSize(110, 100);

		btnMenu.addMouseOverHandler(new MouseOverHandler() {

			@Override
			public void onMouseOver(final MouseOverEvent event) {

				// Create the new popup.
				textoDescritivo.setWidget(new Label(texto));
				textoDescritivo.setPopupPositionAndShow(new PopupPanel.PositionCallback() {
					public void setPosition(int offsetWidth, int offsetHeight) {
						textoDescritivo.setPopupPosition(event.getClientX(), event.getClientY());
						t.schedule(1000);
					}
				});

			}
		});
		
	}
	
	public Widget getBotao(){

		
		return btnMenu;
	}

}
